package MyCode.Swing.JFrameDemo;

import javax.swing.*;
import java.awt.*;

/**
 * 流式布局
 */

public class Gui3 extends JFrame{
    //定义组件
    JButton btn1,btn2,btn3,btn4,btn5,btn6;

    public Gui3(){
        //创建组件
        btn1 = new JButton("Button1");
        btn2 = new JButton("Button2");
        btn3 = new JButton("Button3");
        btn4 = new JButton("Button4");
        btn5 = new JButton("Button5");
        btn6 = new JButton("Button6");

        //添加组件
        add(btn1);
        add(btn2);
        add(btn3);
        add(btn4);
        add(btn5);
        add(btn6);

        //设置流式布局
        setLayout(new FlowLayout(FlowLayout.CENTER));

        //设置窗体属性
        setTitle("流式布局");
        setSize(300,200);

        //禁止用户改变窗体大小
        setResizable(false);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setVisible(true);

        setLocationRelativeTo(null);

    }


    public static void main(String[] args) {
        new Gui3();
    }





}
